const request = require("request");

class HttpUtil {

    /**
     * 同步函数
     */
    synchronous_request(url, type, params, headers) {
        let options = {
            url: url,
            method: type,
            headers: headers,
            qs: params
        };
        return new Promise(function (resolve, reject) {
            request(options, function (error, response, body) {
                if (error) {
                    reject(error);
                } else {
                    resolve(body);
                }
            });
        });
    }
}

module.exports = new HttpUtil();